<#include "/common/head.ftl">

<@showTitle title="${i18n.getMessage('bookstore.order')} > ${i18n.getMessage('search')}">
	<a href="#" onclick="cc('bookstore/showCreateOrder.sgt')">${i18n.getMessage('add')}</a>
</@showTitle>

<div id="error" style="display:none"></div>

<form action="bookstore/searchOrder.sgt" onsubmit="submitForm(this); return false;" onreset="$('error').hide()">
	<fieldset class="fs">
		<legend>Order Info</legend>
		<table id="dataTable" cellspacing="5" cellpadding="0" align="center" style="width:100%">
			<tr>
				<td class="name1">${i18n.getMessage('student.name')}:</td>
				<td>
					<input type="text" value="${studentName!}" name="studentName" style="width:205px"/>
				</td>
				<td class="ta">${i18n.getMessage('user')}:</td>
				<td>
					<select name="userId" style="width:190px">
						<option></option>
						<#list users as user>
							<option value="${(user.id)!}" <#if (user == searchUser!)>selected</#if> >${(user.fullName)!}</option>
						</#list>
					</select>
				</td>
			</tr>
			<tr>
				<td class="name1">${i18n.getMessage('date')}:</td>
				<td>
					<input type="text" value="${date!}" name="date" style="width:184px"/><img class="calendarImg" src="images/calendar/calendar.gif" onclick="displayCalendar(document.forms[0].date, '${i18n.getMessage('format.date')}', this)"/>
				</td>		
			</tr>
			<tr>
				<td class="name1"></td>
				<td>
					<input type="submit" value="${i18n.getMessage('search')}" class="button_style"/> 
				</td>
			</tr>
		</table>
	</fieldset>
</form>
	<fieldset class="fs">
		<legend>Results</legend>
<@display.table id="listTable" name="orders" pagesize="20">
	<@display.column title="${i18n.getMessage('index')}" style="text-align:center">
		${(listTable_rowNum)!}
	</@display.column>
	<@display.column title="${i18n.getMessage('student.name')}">
		${(listTable.studentName)!}
	</@display.column>
	<@display.column title="${i18n.getMessage('date')}" style="text-align:center">
		${(listTable.date)!}
	</@display.column>
	<@display.column title="${i18n.getMessage('bookstore.order.price')}" style="text-align:center">
		${(listTable.totalPrice.amount)!}
	</@display.column>
	<@display.column title="${i18n.getMessage('bookstore.import.detail')}" style="text-align:center;width:70px;">
		<img src="images/books.gif" onclick="cc('bookstore/showEditOrderDetails.sgt?id=${listTable.id}')" style="cursor:pointer"/>
	</@display.column>
	<@display.column title="${i18n.getMessage('edit')}" style="text-align:center;width:50px;">
		<img src="images/edit.gif" onclick="cc('bookstore/showEditOrder.sgt?id=${listTable.id}')" style="cursor:pointer"/>
	</@display.column>
	<@display.column title="${i18n.getMessage('delete')}" style="text-align:center;width:50px;">
		<img src="images/delete.gif" onclick="if(confirm('${i18n.getMessage('dialog.delete')}')) { cc('bookstore/deleteOrder.sgt?id=${listTable.id}'); }" style="cursor:pointer"/>
	</@display.column>
</@display.table>
<p>&nbsp;</p>
</fieldset>

<script>
	updateStudentName = function(obj) {
		var name = obj.form.studentId;
		var studentName = obj.form.studentName;		
		studentName.value = name.options[name.selectedIndex].innerHTML;
	}
</script>

<@ajax.select baseUrl="programlevelsearch.view" source="programId" target="levelId"
	parameters="programId={programId}" executeOnLoad=true/>
	
<@ajax.select baseUrl="levelofferingsearch.view" source="levelId" target="offeringId"
	parameters="levelId={levelId}"/>
	
<@ajax.select baseUrl="OfferingStudentSearch.view" source="offeringId" target="studentId"
	parameters="offeringId={offeringId}"/>